﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharpSoft.Lexing
{
    /// <summary>
    /// 词法分析器异常
    /// </summary>
    public class TextLexerException : Exception
    {
        public TextLexerException(int position, int length, string message)
            : base(message)
        {
            this._Position = position;
            this._Length = length;
        }
        private int _Position;
        /// <summary>
        /// 发生异常的位置
        /// </summary>
        public int Position
        {
            get { return _Position; }
        }

        private int _Length;
        /// <summary>
        /// 异常的可能长度
        /// </summary>
        public int Length
        {
            get { return _Length; }
        }
    }
    /// <summary>
    /// 不可识别的转义序列
    /// </summary>
    public class InvalidEscapeSequenceException : TextLexerException
    {
        public InvalidEscapeSequenceException(int position, string esc)
            : base(position, esc.Length, "不可识别的转义序列：\\" + esc)
        {

        }
    }
}
